#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"supsql.h"
#include"dlg_commmon.h"
#include<qDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow) ,m_ptrSupSql(nullptr)
{
    ui->setupUi(this);
    m_dlgLogin.show();
    auto f=[&](QString str)
    {
        this->show();

        m_id = str;
        if(str.length()==8)
        {
            ui->pushButton->setEnabled(false);
            ui->pushButton_3->setEnabled(false);
            ui->pushButton_4->setEnabled(false);
            ui->pushButton_6->setEnabled(false);
            ui->pushButton_7->setEnabled(false);
            ui->pushButton_8->setEnabled(false);
            ui->pushButton_9->setEnabled(false);
            ui->pushButton_11->setEnabled(false);
        }
        else
        {
            ui->pushButton_2->setEnabled(false);
            ui->pushButton_5->setEnabled(false);
            ui->pushButton_10->setEnabled(false);
        }
        qDebug()<<m_id;
    };

    d = new dlg_commmon;
    m_eval = new dlg_eval;
    connect(&m_dlgLogin,&dlg_login::loginSucceeded,this,f);
    m_ptrSupSql = supsql::getinstance();
    m_ptrSupSql->init();

    //教师基本信息
    connect(ui->pushButton, &QPushButton::clicked, [=]() {
//        t_info = m_ptrSupSql->GetTechInfo(m_id);
//        d->fun2(t_info);
//        d->show();
        d->fun0(m_ptrSupSql->getInfo(new TechToShow(),m_id));
        d->show();
    });

    //学生基本信息
    connect(ui->pushButton_2, &QPushButton::clicked, [=]() {
//        s_info = m_ptrSupSql->GetStuInfo(m_id);
//        d->fun1(s_info);
//        d->show();
        qDebug()<<"开始执行学生信息查看";
        d->fun0(m_ptrSupSql->getInfo(new StuToShow(),m_id));
        d->show();

    });

    //学习经历
    connect(ui->pushButton_5, &QPushButton::clicked, [=]() {
//        stu_exp = m_ptrSupSql->GetStuExpInfo(m_id);
//        d->fun3(stu_exp);
        d->fun0(m_ptrSupSql->getInfo(new StuExp(),m_id));
        d->show();
    });

    //论文及基本信息
    connect(ui->pushButton_3, &QPushButton::clicked, [=]() {
//        ps = m_ptrSupSql->getPaperInfo(m_id);
//        d->fun4(ps);
        d->fun0(m_ptrSupSql->getInfo(new PaperInfo(),m_id));
        d->show();
    });

    //评价信息
    connect(ui->pushButton_10, &QPushButton::clicked, [=]() {
        m_eval->SetStuId(m_id);
        qDebug()<<"1:"<<m_id;
        m_eval->show();
    });

    //科研成果
    connect(ui->pushButton_4,&QPushButton::clicked,[=](){
//        sci_list=m_ptrSupSql->getSciSet(m_id);
//        d->fun5(sci_list);
        d->fun0(m_ptrSupSql->getInfo(new Sci_Result(),m_id));
        d->show();
    });

    //工作经历
    connect(ui->pushButton_6,&QPushButton::clicked,[=](){
//         Work_list=m_ptrSupSql->getWorkExp(m_id);
//         d->fun6(Work_list);
        d->fun0(m_ptrSupSql->getInfo(new Work_exp(),m_id));
         d->show();
    });

    //成长记录信息
    connect(ui->pushButton_7,&QPushButton::clicked,[=](){
//        Dev_list=m_ptrSupSql->getDeleveop(m_id);
//        d->fun7(Dev_list);
        d->fun0(m_ptrSupSql->getInfo(new Develop(),m_id));
        d->show();
    });

    //招聘信息
    connect(ui->pushButton_8,&QPushButton::clicked,[=](){
//        Re_list=m_ptrSupSql->getRecruit();
//        d->fun8(Re_list);
        d->fun0(m_ptrSupSql->getInfo(new Recruit(),m_id,1));
        d->show();
    });

    //应聘信息
    connect(ui->pushButton_9,&QPushButton::clicked,[=](){
//        Ap_list=m_ptrSupSql->getAppc();
//        d->fun9(Ap_list);
        d->fun0(m_ptrSupSql->getInfo(new Appc(),m_id));
        d->show();
    });

    //实习管理
    connect(ui->pushButton_11,&QPushButton::clicked,[=](){
//        Itn_list=m_ptrSupSql->getIntern(m_id);
//        d->fun10(Itn_list);;
        d->fun0(m_ptrSupSql->getInfo(new Intern(),m_id));
        d->show();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

//教师基本信息
void MainWindow::on_pushButton_clicked()
{
    qDebug()<<"教师基本信息";
}

//学生基本信息
void MainWindow::on_pushButton_2_clicked()
{
    qDebug()<<"学生基本信息";

}

//学习经历
void MainWindow::on_pushButton_5_clicked()
{
    qDebug()<<"学习经历";

}

//学生对老师教学评估
void MainWindow::on_pushButton_10_clicked()
{
    qDebug()<<"学生评价";


}

void MainWindow::on_pushButton_4_clicked()
{
    qDebug()<<"科研成果信息";
}


void MainWindow::on_pushButton_7_clicked()
{
    qDebug()<<"成长记录信息";
}


void MainWindow::on_pushButton_6_clicked()
{
    qDebug()<<"工作经历";
}


void MainWindow::on_pushButton_8_clicked()
{
    qDebug()<<"招聘信息";
}

